<template>
    <view>
<!-- - -->
        <uni-status-bar></uni-status-bar>
        <tabBar :currentIndex="3"></tabBar>
<!-- - -->
        <view class="topbg"></view>
        <view class="user-info">
            <view class="user">
                <view class="img">
                    <image :src="userInfo.avatar || '../../static/icon/sc-home-sg@3x.png'" mode="aspectFill"></image>
                </view>
                <view class="text">
                    <text class="username">{{userInfo.username || userInfo.nickname}}</text>
                    <!-- <text class="phone">188 9876 5432</text> -->
                </view>
            </view>
            <!-- <view class="more"></view> -->
        </view>
<!-- - -->
        <view class="order">
            <view class="top">
                <text class="title">我的订单</text>
                <view class="btn" @click="my_order(0)">
                    <text>全部订单></text>
                </view>
            </view>
            <view class="order-item">
                <view class="item" @click="my_order(1)">
                    <view class="img">
                        <image src="../../static/icon/sc-my-dfk@3x.png"></image>
                        <text class="text">待付款</text>
                    </view>
                    <text class="tip" v-if="orderNum.num1 > 0">{{orderNum.num1}}</text>
                </view>
                <view class="item" @click="my_order(2)">
                    <view class="img">
                        <image src="../../static/icon/sc-my-dfh@3x.png"></image>
                        <text class="text">待发货</text>
                    </view>
                    <text class="tip" v-if="orderNum.num2 > 0">{{orderNum.num2}}</text>
                </view>
                <view class="item" @click="my_order(3)">
                    <view class="img">
                        <image src="../../static/icon/sc-my-dsh@3x.png"></image>
                        <text class="text">待收货</text>
                    </view>
                    <text class="tip" v-if="orderNum.num3 > 0">{{orderNum.num3}}</text>
                </view>
                <view class="item" @click="my_order(6)">
                    <view class="img">
                        <image src="../../static/icon/sc-my-ywc@3x.png"></image>
                        <text class="text">已完成</text>
                    </view>
                    <text class="tip" v-if="orderNum.num4 > 0">{{orderNum.num4}}</text>
                </view>
            </view>
        </view>
<!--  -->
        <view class="nt-list">
            <view class="list">
                <view class="left">
                    <image class="img" src="../../static/icon/sc-my-icon-dizhi@3x.png"></image>
                </view>
                <view class="right" @click="addressClick()">
                    <text>收货地址</text>
                    <view class="more"></view>
                </view>
            </view>
            <view class="list">
                <view class="left">
                    <image class="img" src="../../static/icon/sc-my-icon-wenti@3x.png"></image>
                </view>
                <view class="right" @click="problemClick()">
                    <text>常见问题</text>
                    <view class="more"></view>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
    //import uniStatusBar from "../../components/uni-status-bar/uni-status-bar.vue";
    export default {
        /* components:{
            uniStatusBar
        }, */
        data() {
            return {
                title: '',
                orderNum: {},
                userInfo: {}
            }
        },
        mounted() {
            uni.showLoading({
                title: '加载中'
            });
            if(!this.$u.test.isEmpty(this.$store.state.userInfo)) {
                this.userInfo = this.$store.state.userInfo
            }
            this._getorderstatusnum();
        },
        methods: {
            my_order(id){
                uni.navigateTo({
                    url:"/shop/pages/list/myOrder?id="+id
                })
            },
            problemClick(){
                // uni.navigateTo({
                //     url:'/shop/pages/list/problem'
                // })
                uni.navigateTo({
                    url:'/mypages/Customer_service_center/Customer_service_center'
                })
            },
            addressClick(){
                uni.navigateTo({
                    url: "/shop/pages/list/accountDemo1"
                })
            },
            // 获取订单状态数量api
            _getorderstatusnum() {
                this.$u.api.getorderstatusnum().then(res => {
                    this.orderNum = res
                    uni.hideLoading();
                }).catch(err => {
                    uni.hideLoading();
                })
            }
        }
    }
</script>

<style lang="scss">
    .topbg{
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 540rpx;
        background-image: url(../../static/icon/user-bg@2x.png);
        background-size: 100%;
        z-index: -1;
    }
    .user-info{
        margin: 30rpx;
        display: flex;
        align-items: center;
        .user{
            display: flex;
            align-items: center;
            flex-wrap: wrap;
            width: 600rpx;
            .img{
                width: 140rpx;
                height: 140rpx;
                border: 8rpx solid #fff;
                box-shadow: 0 10rpx 30rpx rgba(0,0,0,0.05);
                border-radius: 50%;
                overflow: hidden;
                image{
                    width: 100%;
                    height: 100%;
                }
            }
            .text{
                width: 400rpx;
                display: flex;
                flex-wrap: wrap;
                margin: 8rpx 0 0 30rpx;
                .username{
                    width: 100%;
                    font-size: 45rpx;
                    color: #fff;
                    font-weight: bold;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    white-space: nowrap;
                }
                .phone{
                    width: 100%;
                    font-size: 28rpx;
                    color: #ffe7de;
                    margin-top: 20rpx;
                }
            }
        }
        .more{
            width: 30rpx;
            height: 30rpx;
            background-image: url(../../static/icon/my-list-more@3x.png);
            background-size: 100%;
            margin-left: auto;
        }
    }
// ---------------------------------------------------------------------------------------------
.order{
    margin: 60rpx 30rpx 30rpx 30rpx;
    background-color: #fff;
    border-radius: 20rpx;
    display: flex;
    flex-wrap: wrap;
    padding-bottom: 60rpx;
    .top{
        width: 100%;
        padding: 30rpx;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        .title{
            font-size: 32rpx;
            color: #191919;
            font-weight: bold;
        }
        .btn{
            height: 48rpx;
            padding: 0 20rpx;
            border-radius: 99px;
            background-color: #f2f2f2;
            margin-left: auto;
            text{
                color: #999;
                font-size: 24rpx;
                font-weight: bold;
            }
        }
    }
    .order-item{
        width: 100%;
        display: flex;
        margin: 30rpx 0;
        .item{
            display: flex;
            justify-content: center;
            position: relative;
            flex: 1;
            flex-wrap: wrap;
            .img{
                width: 90rpx;
                height: 90rpx;
                image{
                    width: 100%;
                    height: 100%;
                }
            }
            .text{
                color: #191919;
                font-size: 24rpx;
                text-align: center;
                width: 100%;
                display: block;
                font-weight: bold;
            }
            .tip{
                height: 40rpx;
                min-width: 40rpx;
                font-size: 20rpx;
                text-align: center;
                color: #fff;
                font-weight: bold;
                background-color: #ff4200;
                border-radius: 99px;
                padding: 0 10rpx;
                box-sizing: border-box;
                line-height: 40rpx;
                position: absolute;
                right: 10rpx;
                top: -10rpx;
            }
        }
    }
}
// ---------------------------------------------------------------------------------------------
.nt-list{
    margin: 30rpx;
    border-radius: 20rpx;
    overflow: hidden;
    background-color: #fff;
    .list{
        height: 112rpx;
        display: flex;
        align-items: center;
        .left{
            height: 100%;
            padding: 0 30rpx;
            display: flex;
            align-items: center;
            .img{
                width: 56rpx;
                height: 56rpx;
            }
        }
        .right{
            border-bottom: 1px solid #f6f6f6;
            display: flex;
            align-items: center;
            flex: 1;
            height: 100%;
            text{
                font-size: 32rpx;
                color: #191919;
                font-weight: bold;
            }
            .more{
                width: 30rpx;
                height: 30rpx;
                background-image: url(../../static/icon/my-list-more@3x.png);
                background-size: 100%;
                margin-left: auto;
                margin-right: 30rpx;
            }
        }
    }
}

.nt-list .list:last-of-type .right{
    border: none;
}
</style>
